﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SharpKit.JavaScript;
using System.Collections;

namespace WebDesigner.Client
{
    [JsType(JsMode.Prototype)]
    class JsArrayEnumerator : IEnumerator
    {
        public JsArrayEnumerator(JsArray array)
        {
            Array = array;
            Index = -1;
        }
        JsArray Array;

        public bool MoveNext()
        {
            Index++;
            return Index < Array.length;
        }
        int Index;
        public object Current
        {
            get
            {
                return Array[Index];
            }
        }

        #region IDisposable Members

        public void Dispose()
        {
        }

        #endregion

        #region IEnumerator Members

        object IEnumerator.Current
        {
            get { throw new NotImplementedException(); }
        }

        public void Reset()
        {
            Index = -1;
        }

        #endregion
    }

    [JsType(JsMode.Prototype, Name = "Array", NativeEnumerator = false)]
    class JsArray2 : JsArray
    {
        [JsMethod(Export = false)]
        public JsArray2()
        {
        }
        public new IEnumerator GetEnumerator()
        {
            return new JsArrayEnumerator(this);
        }
    }

}